home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-16 | 5.0 KB | 184 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWColorP.cpp
- // Release Version: $ ODF 3 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWCOLORP_H
- #include "FWColorP.h"
- #endif
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__COLORPICKER__)
- #include <ColorPicker.h>
- #endif
-
- //========================================================================================
- // Runtime info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwtoolbx
- #endif
-
-
- //========================================================================================
- // class FW_CColorPicker
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::FW_CColorPicker
- //----------------------------------------------------------------------------------------
-
- FW_CColorPicker::FW_CColorPicker() :
- fColor()
- {
- for (unsigned short i = 0; i < 16; ++i)
- fCustomColors[i] = FW_kRGBWhite;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::FW_CColorPicker
- //----------------------------------------------------------------------------------------
-
- FW_CColorPicker::FW_CColorPicker(FW_CReadableStream& stream) :
- fColor()
- {
- Read(stream);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::~FW_CColorPicker
- //----------------------------------------------------------------------------------------
-
- FW_CColorPicker::~FW_CColorPicker()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::SetColor
- //----------------------------------------------------------------------------------------
-
- void FW_CColorPicker::SetColor(const FW_CColor& color)
- {
- fColor = color;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::GetColor
- //----------------------------------------------------------------------------------------
-
- FW_CColor FW_CColorPicker::GetColor() const
- {
- return fColor;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::PickNewColor
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CColorPicker::PickNewColor()
- {
- FW_Boolean result = FALSE;
-
- #ifdef FW_BUILD_WIN
- #if 0
- BR_CEventHandler::EventHandlerID dismisser = cmdCancel;
- BR_CApplication *App = BR_CApplication::GetApplication();
-
- CHOOSECOLOR cc;
-
- // Fill Windows parameters structure
- cc.lStructSize = sizeof(cc);
- cc.hwndOwner = BR_CAppDesktop::GetAppDesktop()->GetPlatformWindow();
- cc.rgbResult = fColor.GetRGB();
- cc.lpCustColors = fCustomColors;
- cc.Flags = CC_RGBINIT;
-
- App->SetAppModal();
-
- // Call a function on COMMDLG.DLL
- if (ChooseColor(&cc))
- {
- // Set result to Ok
- dismisser = cmdOk;
-
- // And update our color value
- fColor = cc.rgbResult;
- }
-
- App->ClearAppModal();
- #endif
- #endif
-
- #ifdef FW_BUILD_MAC
-
- RGBColor inColor = fColor;
- RGBColor outColor;
-
- Point where = {-1, - 1};
-
- if (::GetColor(where, (ConstStr255Param)"\p", &inColor, &outColor))
- {
- result = TRUE;
-
- // And update our color value
- fColor = outColor;
- }
- #endif
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::Read
- //----------------------------------------------------------------------------------------
-
- void FW_CColorPicker::Read(FW_CReadableStream& stream)
- {
- for (short i = 0; i < 16; ++i)
- stream >> fCustomColors[i];
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::Write
- //----------------------------------------------------------------------------------------
-
- void FW_CColorPicker::Write(FW_CWritableStream& stream) const
- {
- for (short i = 0; i < 16; ++i)
- stream << fCustomColors[i];
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::operator>>
- //----------------------------------------------------------------------------------------
-
- FW_CReadableStream& operator>>(FW_CReadableStream& stream, FW_CColorPicker& colorPicker)
- {
- colorPicker.Read(stream);
- return stream;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CColorPicker::operator<<
- //----------------------------------------------------------------------------------------
-
- FW_CWritableStream& operator<<(FW_CWritableStream& stream, const FW_CColorPicker& colorPicker)
- {
- colorPicker.Write(stream);
- return stream;
- }
-